package org.practice.aspectj;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;

/**
 * 基于Aspect的切面，要另外引入AspectJ类库(aspectjrt.jar,aspectjweaver.jar)
 * AspectJ是面向切面编程的框架,专门用来实现动态代理(AOP编程)的类库
 * 除了使用aop:aspect标签，还有用@Aspect注解的方式代替配置文件，配置文件只需配置<aop:aspectj-autoproxy/>
 * @author jack
 */
//@Aspect
public class ExceptionHandler{
	
	private Logger logger = Logger.getLogger(this.getClass().getName());
    
	//@AfterThrowing(pointcut="execution(* org.practice.service..*.*(..))",throwing="ex")
    public void afterThrowing(JoinPoint point,Exception ex) throws Throwable {
    	logger.log(Level.INFO, point.getArgs()[0] + " 执行 " + point.getSignature().getName() + " 时有异常抛出..."+ex.getMessage());
    }
}
